﻿#region Opis pliku
//-----------------------------------------------------------------------------
// HitEmitter.cs
// Autor: Jan Fraś
// 30.10.2012
//-----------------------------------------------------------------------------
#endregion

#region Using..

using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

#endregion

namespace pogra
{
    /// <summary>
    /// emiter odprysków po przyjęciu obrażeń
    /// </summary>
    class HitEmitter: Emitter
    {

        float rotation;

        public HitEmitter(Vector2 Position, float rotation) :
            base(Position, null) { this.rotation = rotation; life = TimeSpan.FromMilliseconds(20); }


        protected override void GenerateParticles()
        {
            maxParticles = 30;
            // generacja nowych cząsteczek
           
            while (particleList.Count < maxParticles && life > TimeSpan.Zero)
            {
                Color color = Color.Gold;
                double lifeSeconds = random.NextDouble() * 0.001 + 0.001;
                double velocity = random.NextDouble() * 500;
                double rotation = random.NextDouble() * Math.PI - Math.PI/2 + (double)this.rotation + Math.PI;
                particleList.AddLast(new HitParticle(Position, (float)velocity, (float)rotation, TimeSpan.FromSeconds(0.05)));
            }
        }
    }
}
